package genetic2;

import java.util.Map.*;
import java.util.*;
import warehouse.Constants;
import warehouse.Persistance;

/**
 *
 * @author Manolescu Razvan
 */

public class Controller {
    public static Population pop;
    
    public static void main(String... args) throws InterruptedException{
          final Persistance p = new Persistance();
          final Map<String, Float> probMap = External.initFromFile(Constants.COL_PROBABILITY_FILE_PATH);
          final Map<String, List<ColumnStatistics>> statistics = External.initColumnStatistics(probMap, p);
          
          pop = new Population(statistics); 
          
          Population.best = pop.inds[0];
           
         while(true){

             System.out.println(" Fitness "+Population.best.getFitness() +" Size(KB) "+ 
                     Population.best.getSizeInKb()+ " prob " + Population.best.getAllProb()+"       " +Population.changeCounter);
             System.out.println(pop);
             
             if( Population.curGen >= GeneticParameters.MAXGENERATIONS ||
                     Population.changeCounter >= GeneticParameters.MAXNOCHANGE )
                 break;
             
             Thread.sleep( GeneticParameters.TIMEOUT );
             pop.newGeneration();
         }
         
         System.out.println("BEST "+ Population.best);

    }
  
}
